#第一题
#s="高举中国特色社会主义伟大旗帜，全面贯彻新时代中国特色社会主义思想，弘扬伟大建党精神，自信自强、守正创新，踔厉奋发、勇毅前行，为全面建设社会主义现代化国家、全面推进中华民族伟大复兴而团结奋斗。"
#print(s[::-1])#字符串切片法
#print(''.join(reversed(s)))

#第二题
#for i in range(1,10):
#    for j in range(1,i+1):
#       print(f"{j}x{i}={i*j}",end="\t")
#    print()

#第三题
#def sum_of_odds():
#    return sum(i for i in range(1,101) if i%2 !=0)

#print(sum_of_odds())

#第四题
#import turtle
#canvas = turtle.Screen()
#canvas.title('绘制六边形')
#canvas.bgcolor('white')
#t = turtle.Turtle()
#t.pensize(2)
#t.color('black')
#for i in range(6):
#    t.forward(200)
#    t.left(60)

#t.hideturtle()
#canvas.mainloop()

#第五题
import random

class RockPaperScissors:
    def __init__(self):
        self.choices = ['石头', '剪刀', '布']
        self.user_choice = None
        self.computer_choice = None

    def get_user_choice(self):
        while self.user_choice not in self.choices:
            self.user_choice = input("请选择石头、剪刀或布: ")
        return self.user_choice

    def get_computer_choice(self):
        self.computer_choice = random.choice(self.choices)
        return self.computer_choice

    def determine_winner(self):
        if self.user_choice == self.computer_choice:
            return "平局！"
        elif (self.user_choice == '石头' and self.computer_choice == '剪刀') or \
             (self.user_choice == '剪刀' and self.computer_choice == '布') or \
             (self.user_choice == '布' and self.computer_choice == '石头'):
            return "你赢了！"
        else:
            return "你输了！"

    def play(self):
        self.user_choice = self.get_user_choice()
        self.computer_choice = self.get_computer_choice()
        print(f"你选择了: {self.user_choice}")
        print(f"电脑选择了: {self.computer_choice}")
        result = self.determine_winner()
        print(result)

game = RockPaperScissors()
game.play()
